#coding: utf-8
from django.db import models

# Create your models here.

class housingProject(models.Model):
    name=models.CharField('楼盘名字',maxlength=50)
    class Meta:
        db_table = 'housingproject'



leaseSale=(
(0,'出租'),
(1,'求租'),
(2,'出售'),
(3,'求购'),
)

typeOfFlat=(
(0,'单房'),
(1,'一房一厅'),
(2,'两房一厅'),
(3,'两房两厅'),
(4,'三房一厅'),
(5,'三房两厅及以上'),
)

purpose=(
(0,'别墅'),
(1,'住宅'),
(2,'写字楼'),
(3,'厂房/loft三种类型'),
)


class Building(models.Model):
    leaseSale=models.SmallIntegerField('租售类型',default=0,choices=leaseSale,db_index=True)
    title=models.CharField('标题',maxlength=100)
    housingProject=models.ForeignKey(housingProject,db_index=True)
    squareFootage=models.CharField('房屋面积',maxlength=10)
    typeOfFlat=models.SmallIntegerField('户型',default=0,choices=typeOfFlat)

    purpose=models.SmallIntegerField('房屋类型',default=0,choices=purpose)
    yearBuilt=models.SmallIntegerField('楼盘竣工时间')

    fitment=models.CharField('房屋设备',maxlength=300)
    floor=models.SmallIntegerField('楼层',default=1)
    totalFloors=models.SmallIntegerField('总楼层',default=1)
    originalUrl=models.CharField('原url地址',maxlength=100,unique=True)
    originalUserName=models.CharField('原发布人用户名',maxlength=100)
    agent=models.CharField('中介机构',maxlength=50)
    phoneNum=models.CharField('电话',maxlength=50)
    contactName=models.CharField('联系人',maxlength=30)
    email=models.CharField(maxlength=50)
    userId=models.IntegerField('城的立方用户Id')
    userName=models.CharField('城的立方用户名',maxlength=30)
    isHidden=models.BooleanField(default=False,db_index=True)
    minimal=models.CharField('最小租期(深房)',maxlength=10)
    decoration=models.CharField('装修程度(深房)',maxlength=50)
    exposure=models.CharField('朝向',maxlength=10)
    description=models.TextField('详细描述')
    class Meta:
        db_table = 'building'

class BuildingPrice(models.Model):
    building=models.ForeignKey(Building,db_index=True)
    price=models.CharField('价格',maxlength=10)
    postDate=models.DateField('发布时间',db_index=True)
    limitDate=models.DateField('信息有效时间')
    class Meta:
        db_table = 'buildingprice'
        unique_together = (("building", "postDate"),)

class AvgPrice(models.Model):
    housingProject=models.ForeignKey(housingProject,db_index=True)
    price=models.CharField('价格',maxlength=10)
    postDate=models.DateField('发布时间',db_index=True)
    class Meta:
        db_table = 'avgprice'
        unique_together = (("housingProject", "postDate"),)